package com.telit.firecommand.config.properties;

import com.hikvision.artemis.sdk.config.ArtemisConfig;
import com.telit.firecommand.constant.FireConstant;
import com.telit.firecommand.util.EquipStationUtils;
import com.telit.firecommand.util.IotUtil;
import com.telit.firecommand.util.MaterialUtils;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;


/**
 * 属性类
 *
 * @author yuezhuang
 * @date 2022-08-30
 */
@Component
@Data
@ConfigurationProperties(prefix = FireConstant.FIRE_PREFIX)
public class FireProperties {

    private Boolean intranetEnvironment = true;

    private String intranetIp = "";

    private String extranetIp = "";

    @NestedConfigurationProperty
    private HaikangProperties haikang = new HaikangProperties();

    @NestedConfigurationProperty
    private H5Properties h5 = new H5Properties();

    @NestedConfigurationProperty
    private MaterialProperties material = new MaterialProperties();

    @NestedConfigurationProperty
    private EquipStationProperties equipStation = new EquipStationProperties();

    @NestedConfigurationProperty
    private DBWProperties dbw = new DBWProperties();

    @NestedConfigurationProperty
    private IotProperties iot = new IotProperties();

    @PostConstruct
    public void init() {
        ArtemisConfig.host = haikang.getHost();
        ArtemisConfig.appKey = haikang.getAppKey();
        ArtemisConfig.appSecret = haikang.getAppSecret();

        MaterialUtils.init(material);
        EquipStationUtils.init(equipStation);
        IotUtil.init(iot);
    }

}
